/*
 *  sparsematrix.h
 *  EPPI-0.0
 *
 *  Created by Juan Carlos García Orden on 07/07/2010.
 *
 */
#ifndef _sparsematrix_h_
#define _sparsematrix_h_

#include <iostream>
#include <vector>
//Arma #include <armadillo>
#include <Eigen/Dense>
#include "slu_ddefs.h"

using namespace std;
//Arma using namespace arma;
using namespace Eigen;

class sparseMatrix
{
public:
	int n;		// Matrix size (assumed squared)
	int* ia;
	int* ja;
	double* values;
	int nnz;
	int nrhs;
	string typeName;

public:
	sparseMatrix(string);
	sparseMatrix(string,int, int);
	virtual ~sparseMatrix(){};
	
	void resize(int&, int&);
	double readElement(int&, int&);
	double readElement(int&);
	void writeElement(double, int&, int&);
	void writeElement(double, int&);
	void reset(void);
	int rows()	{return n;}
	void sparsePattern(vector<int>&, vector<int>&);
	void setTypeName(string);
	
	/** Virtual functions */
	virtual void initMatrices(void)=0;
	virtual void initVectors(int)=0;
	virtual void factorize(int)=0;
	virtual void subsSolve(vector<double>&)=0;
//Arma	virtual void subsSolve(rowvec &)=0;
	virtual void subsSolve(RowVectorXd &)=0;
	virtual void subsSolve(VectorXd &)=0;
	virtual void subsSolveTrans(vector<vector<double> >&)=0;
//	virtual void subsSolveTrans(double*)=0;
//Arma	virtual void subsSolveTrans(mat &)=0;
	virtual void subsSolveTrans(MatrixXd &)=0;
	virtual void subsSolveTrans(SuperMatrix&, SuperMatrix&){};
	virtual void copyMatrix(sparseMatrix *)=0;
	
};
#endif
